<?php
$options = getopt('f:k:');
if (empty($options['k'])) {
    echo "Keywords must be set. Use -k <keyword1,keyword2,etc>\n";
}
elseif (empty($options['f'])) {
    echo "Logfile must be set. Use -f <filename>\n";
}
else {
    require_once 'exceptions/AppRuntimeException.php';
    require_once 'DAO/Links.php';
    require_once 'modules/RepositoryLinks.php';
    try {
        $keywords = explode(',', $options['k']);
        $repoLinks = new RepositoryLinks();
        $repoLinks->setKeywords($keywords)->parse($options['f']);
    } catch (PDOException $e) {
        echo "Connection failed: {$e->getMessage()}\n";
    } catch (App_Runtime_Exception $e) {
        echo "App runtime exception: {$e->getMessage()}\n";
    }
}